#include "CharacterPool.h"

#include <fstream>
#include <string>

using std::ifstream;
using std::string;



void CharacterPool::load(istream& input) {
	string characterName;

	int phaseCount;
	int spellCount;
	string spellName;

	while (input >> characterName) {
		input >> phaseCount;

		spellSetPool.insert(map<string, SpellSet>::value_type(characterName, SpellSet()));
		SpellSet& spellSet = spellSetPool[characterName];

		for (int i = 0; i != phaseCount; i++) {
			input >> spellCount;

			spellSet.push_back(vector<Spell*>());
			vector<Spell*>& spells = spellSet[spellSet.size()-1];

			for (int i = 0; i != spellCount; i++) {
				input >> spellName;
				spells.push_back(&spellPool.get(spellName));
			}
		}

		pool.insert(map<string, Character>::value_type(characterName, Character(input, spellSet)));
	}
}
